import React from 'react';
import cn from 'classnames';
import PropTypes from 'prop-types';
import styles from './index.less';

// 部门
const Department = ({ level, value, children, className, ...rest }) => (
    <div
        className={cn(className, styles.department, {
            [styles.departmentSm]: level === 3,
            [styles.departmentLg]: level === 1
        })}
        {...rest}
    >
        {children}
        {typeof value !== 'undefined' && !Number.isNaN(value) && ` (${value})`}
    </div>
);

Department.propTypes = {
    // 等级
    level: PropTypes.oneOf([1, 2, 3]),
    // 值
    value: PropTypes.oneOfType([PropTypes.number, undefined])
};
Department.defaultProps = {
    level: 2,
    value: undefined
};

export default Department;
